﻿<?xml version="1.0" encoding="utf-8"?>
<Application x:Class="FormValidationExample.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:System="clr-namespace:System;assembly=mscorlib"
             mc:Ignorable="d">
  <Application.Resources>
		<ControlTemplate x:Key="DefaultErrorTemplate">
			<Grid x:Name="container">
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="*" />					
				</Grid.ColumnDefinitions>

				<AdornedElementPlaceholder Grid.Column="0"
										   Name="customAdorner"
										   VerticalAlignment="Center">					
				</AdornedElementPlaceholder>

				<Border x:Name="ValidationErrorElement"
						BorderBrush="#FFDB000C"
						BorderThickness="1"
						CornerRadius="1"
						ToolTip="{Binding ElementName=customAdorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">
					<Grid Background="Transparent"
						  HorizontalAlignment="Right"
						  Height="12"
						  Margin="1,-4,-4,0"
						  VerticalAlignment="Top"
						  Width="12">
						<Path Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z"
							  Fill="#FFDC000C"
							  Margin="1,3,0,0" />
						<Path Data="M 0,0 L2,0 L 8,6 L8,8"
							  Fill="#ffffff"
							  Margin="1,3,0,0" />
					</Grid>
				</Border>

				<Border Grid.Column="1"
						Background="Red"
						HorizontalAlignment="Right"
						VerticalAlignment="Center"
						Width="15"
						Height="15"
						Margin="0,0,5,0"
						CornerRadius="10"
						ToolTip="{Binding ElementName=customAdorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">
					<TextBlock Text="!"
							   VerticalAlignment="center"
							   HorizontalAlignment="center"
							   FontWeight="Bold"
							   Foreground="white">
					</TextBlock>
				</Border>
			</Grid>
			
			<!--<Grid>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="*" />
					<ColumnDefinition Width="20" />
				</Grid.ColumnDefinitions>

				<AdornedElementPlaceholder Grid.Column="0" 
										   Name="customAdorner"
										   VerticalAlignment="Center">
					<Border BorderBrush="red"
							BorderThickness="1" />
				</AdornedElementPlaceholder>
				
				<Border Grid.Column="1" 
						Background="Red"
						DockPanel.Dock="right"
						Margin="5,0,0,0"
						Width="20"
						Height="20"
						CornerRadius="10"
						ToolTip="{Binding ElementName=customAdorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}">
					<TextBlock Text="!"
							   VerticalAlignment="center"
							   HorizontalAlignment="center"
							   FontWeight="Bold"
							   Foreground="white">
					</TextBlock>
				</Border>
				
			</Grid>-->

		</ControlTemplate>
	  
		<Style TargetType="{x:Type TextBox}">
			<Setter Property="Validation.ErrorTemplate"
					Value="{StaticResource DefaultErrorTemplate}" />
		</Style>
		<Style TargetType="{x:Type PasswordBox}">
			<Setter Property="Validation.ErrorTemplate"
					Value="{StaticResource DefaultErrorTemplate}" />
		</Style>
	</Application.Resources>
</Application>